using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Builder
{
  public partial class PlayerImport : Form
  {
    private string m_NavigateURL;
    public string m_PlayerScreenHtml;
    public string m_PlayerUrl;
    public Boolean m_StorePlayerURL = true;

    public PlayerImport(string NavigateURL)
    {
      if (NavigateURL.Length > 0)
      {
        m_NavigateURL = NavigateURL;
      }
      InitializeComponent();
    }



    private void btnImport_Click(object sender, EventArgs e)
    {
      this.DialogResult = DialogResult.OK;
      m_PlayerScreenHtml = wbPlayerData.DocumentText;
      m_StorePlayerURL = chckbxStorePlayerURL.Checked;
      m_PlayerUrl = txtbxUrl.Text;
      this.Hide();
    }

    private void btnCancel_Click(object sender, EventArgs e)
    {
      this.DialogResult = DialogResult.Cancel;
      this.Close();
    }

    private void PlayerImport_Shown(object sender, EventArgs e)
    {
      wbPlayerData.Navigate(m_NavigateURL);
    }

    private void button1_Click(object sender, EventArgs e)
    {
      wbPlayerData.Navigate(txtbxUrl.Text);
    }

    private void PlayerImport_Load(object sender, EventArgs e)
    {

      txtbxUrl.Text = m_NavigateURL;
    }

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
      if (e.KeyChar == 13)
      {
        wbPlayerData.Navigate(txtbxUrl.Text);
      }
    }

    private void wbPlayerData_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
      txtbxUrl.Text = wbPlayerData.Url.ToString();
    }

    private void wbPlayerData_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      btnImport.Enabled = true;
      lblStatus.Text = "Loaded";
    }

    private void wbPlayerData_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
      btnImport.Enabled = false;
      lblStatus.Text = "Loading page...";
    }


  }
}